package com.cg.busniess.controller;

/**
 * Created by SimonZou on 16/3/7.
 */

import com.alibaba.fastjson.JSON;
import com.cg.busniess.entity.UserInfo;
import com.cg.system.entity.Message;
import com.sun.javafx.tools.packager.Log;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/admin")
public class index {
    @RequestMapping("/index")
    public ModelAndView index(){
        return new ModelAndView("indexLogin");
    }
    @RequestMapping("/bank")
    public ModelAndView bank(){
        return new ModelAndView("admin.bank");
    }
    @RequestMapping("/frbank")
    public String frBank(){
        return "freemarker";
    }
    @RequestMapping(value = "/doLogin",method = RequestMethod.POST ,produces = "application/json;charset=utf-8")
    public @ResponseBody String doLogin(HttpServletRequest request, HttpServletResponse response,UserInfo userInfo){
        HttpSession session = request.getSession();
        session.setAttribute("userInfo",userInfo);
//        Log.info("session 用户登录成功");
        return JSON.toJSONString(new Message("登录成功",1,null,null));
    }
    @RequestMapping("/main")
    public String mainPage(){
        return "main";
    }

}
